package com.zhc.dejingapi.pojo.erp;

import com.zhc.dejingapi.entity.BomworkEntity;
import com.zhc.dejingapi.utils.PubInfoUtils;
import lombok.Data;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;

@Data
public class BomworkMainModel {

    //@TableId(value = "main_id", type = IdType.AUTO)
    private Long mainId;

    //@TableField("ERI")
    private String eri;

    //@TableField("SRCERI")
    private String srceri;

    //@TableField("SDATE")
    private String sdate;//日期

    //@TableField("CODE") 工单号
    private String code;

    //@TableField("MAKER")  生产单位
    private String maker;

    //@TableField("MPROD") 成品编号
    private String mprod;

    //@TableField("QTY") 需求数量
    private long qty;

    //@TableField("SRCQTY") 来源需求数量
    private long srcqty;

    //@TableField("DUEDATE") 预计完工日
    private String duedate;

    //@TableField("PROJNO") 项目代码
    private String projno;

    //@TableField("CLOSETYPE") 结案类
    private Integer closetype;

    //@TableField("LINDATE") 最后入库日
    private String lindate;

    //@TableField("ENDDATE") 实际完工日
    private String enddate;

    //@TableField("PRNIMMED")  立即打印
    private Integer prnimmed;

    //@TableField("PRNONCE") 是否打印
    private Integer prnonce;

    //@TableField("ACCGEN") 传输凭证
    private Integer accgen;

    //@TableField("DPTNO") 上传部门
    private String dptno;

    //@TableField("ACCNO") 凭证编号
    private String accno;

    //@TableField("ACCDESC")
    private String accdesc;

    //@TableField("INQTY")
    private Double inqty;

    //@TableField("GOTQTY")
    private Double gotqty;

    //@TableField("COMQTY")
    private Double comqty;

    //@TableField("ARTICLE")
    private String article;

    //@TableField("MEMO")
    private String memo;

    //@TableField("EDITOR")
    private String editor;

    //@TableField("SCRUTINY")
    private String scrutiny;

    //@TableField("ADSTSUBJ")
    private String adstsubj;

    //@TableField("SUBJAMT")
    private Double subjamt;

    //@TableField("WORKSUBJ")
    private String worksubj;

    //@TableField("EXPSUBJ")
    private String expsubj;

    //@TableField("INCOST")
    private Double incost;

    //@TableField("PRODCOST")
    private Double prodcost;

    //@TableField("WORKCOST")
    private Double workcost;

    //@TableField("EXP")
    private Double exp;

    //@TableField("PLUSSUB")
    private Double plussub;

    //@TableField("TOTCOST")
    private Double totcost;

    //@TableField("CLOSEPRC")
    private Double closeprc;

    //@TableField("TPROD")
    private String tprod;

    //@TableField("TQTY")
    private Double tqty;

    //@TableField("TSERIAL")
    private Integer tserial;

    //@TableField("SHIPMARK")
    private String shipmark;

    //@TableField("SHIPMARKERI")
    private String shipmarkeri;

    //@TableField("SPEC")
    private String spec;

    //@TableField("WORKTYPE")
    private Integer worktype;

    //@TableField("BEGINDATE")
    private String begindate;

    //@TableField("RBEGINDATE")
    private String rbegindate;

    //@TableField("CURR")
    private String curr;

    //@TableField("SPRICE")
    private Double sprice;

    //@TableField("SEXP")
    private Double sexp;

    //@TableField("SEXPSUBJ")
    private String sexpsubj;

    //@TableField("GWN")
    private String gwn;

    //@TableField("BQTY")
    private Double bqty;

    //@TableField("RCOSTFLAG")
    private Integer rcostflag;

    //@TableField("PCODE")
    private String pcode;

    //@TableField("PWTYPE")
    private Integer pwtype;

    //@TableField("INVERTFLAG")
    private Integer invertflag;

    //@TableField("QTQTY")
    private Double qtqty;

    //@TableField("PLANDAY")
    private String planday;

    //@TableField("STATUS1")
    private Integer status1;

    //@TableField("STATUS2")
    private Integer status2;

    //@TableField("STATUS3")
    private Integer status3;

    //@TableField("STATUS4")
    private Integer status4;

    //@TableField("EDITORCODE")
    private String editorcode;

    //@TableField("LASTEDITOR")
    private String lasteditor;

    //@TableField("COMPNO")
    private String compno;

    //@TableField("NEEDPRS")
    private Integer needprs;

    //@TableField("SRCTRACK")
    private Integer srctrack;

    //@TableField("PRODPRSNO")
    private String prodprsno;

    //@TableField("VPNO")
    private String vpno;

    //@TableField("VLIDDATE")
    private String vliddate;

    //@TableField("STATUS5")
    private Integer status5;

    //@TableField("STATUS6")
    private Integer status6;

    //@TableField("STATUS7")
    private Integer status7;

    //@TableField("STATUS8")
    private Integer status8;

    //@TableField("STATUS9")
    private Integer status9;

    //@TableField("STATUS10")
    private Integer status10;

    //@TableField("NEDERI")
    private String nederi;

    //@TableField("ORDERI")
    private String orderi;

    //@TableField("WORKTIME")
    private Double worktime;

    //@TableField("MERGEERI")
    private String mergeeri;

    //@TableField("MERGEFLAG")
    private Integer mergeflag;

    //@TableField("OLDBEGINDATE")
    private String oldbegindate;

    //@TableField("OLDDUEDATE")
    private String oldduedate;

    //@TableField("PKERI")
    private String pkeri;

    //@TableField("GETQTY")
    private Double getqty;

    //@TableField("OUQTY")
    private Double ouqty;

    //@TableField("OTHERUNIT")
    private String otherunit;

    //@TableField("INOUQTY")
    private Double inouqty;

    //@TableField("OUQTYNOTCALC")
    private Integer ouqtynotcalc;

    //@TableField("ADSTINQTY")
    private Double adstinqty;

    //@TableField("ADSTINAMT")
    private Double adstinamt;

    //@TableField("PRSWORKCOST")
    private Double prsworkcost;

    //@TableField("PRSEXP")
    private Double prsexp;

    //@TableField("PRSSEXP")
    private Double prssexp;

    //@TableField("ISTODSPWORK")
    private Integer istodspwork;

    //@TableField("AMEXP")
    private Double amexp;

    //@TableField("ISPRSALLT")
    private Integer isprsallt;

    //@TableField("MEDQTY")
    private Double medqty;

    //@TableField("ISDSGWORK")
    private Integer isdsgwork;

    //@TableField("PHSQTY")
    private Double phsqty;

    //@TableField("BOMVER")
    private String bomver;

    //@TableField("ORDBOMERI")
    private String ordbomeri;

    //@TableField("TOTWORKTIME")
    private Double totworktime;

    //@TableField("OMEDQTY")
    private Double omedqty;

    //@TableField("USECOST1")
    private Double usecost1;

    //@TableField("USECOST2")
    private Double usecost2;

    //@TableField("USECOST3")
    private Double usecost3;

    //@TableField("USECOST4")
    private Double usecost4;

    //@TableField("USECOST5")
    private Double usecost5;

    //@TableField("USECOST6")
    private Double usecost6;

    //@TableField("USECOST7")
    private Double usecost7;

    //@TableField("USECOST8")
    private Double usecost8;

    //@TableField("USECOST9")
    private Double usecost9;

    //@TableField("USECOST10")
    private Double usecost10;

    //@TableField("AUDITSTATE")
    private Integer auditstate;

    //@TableField("BOMTYPE")
    private Integer bomtype;

    //@TableField("BOMERI")
    private String bomeri;

    //@TableField("HASBOMWORK3")
    private Integer hasbomwork3;

    //@TableField("SCRUTINY1")
    private String scrutiny1;

    //@TableField("SCRDATE1")
    private String scrdate1;

    //@TableField("DISVARY")
    private Integer disvary;

    //@TableField("SPLITERI")
    private String spliteri;

    //@TableField("SPLITQTY")
    private Double splitqty;

    //@TableField("SPLITFLAG")
    private Integer splitflag;

    //@TableField("EQUIPCODE")
    private String equipcode;

    //@TableField("PUSERFLD1")
    private String puserfld1;

    //@TableField("PUSERFLD2")
    private String puserfld2;

    //@TableField("PUSERFLD3")
    private String puserfld3;

    //@TableField("PUSERFLD4")
    private String puserfld4;

    //@TableField("PUSERFLD5")
    private String puserfld5;

    //@TableField("PUSERFLD6")
    private String puserfld6;

    //@TableField("PUSERFLD7")
    private String puserfld7;

    //@TableField("PUSERFLD8")
    private String puserfld8;

    //@TableField("PUSERFLD9")
    private String puserfld9;

    //@TableField("PUSERFLD10")
    private String puserfld10;

    //@TableField("PUSERFLD11")
    private String puserfld11;

    //@TableField("PUSERFLD12")
    private String puserfld12;

    //@TableField("PUSERFLD13")
    private String puserfld13;

    //@TableField("PUSERFLD14")
    private String puserfld14;

    //@TableField("PUSERFLD15")
    private String puserfld15;

    //@TableField("PUSERFLD16")
    private String puserfld16;

    //@TableField("PUSERFLD17")
    private String puserfld17;

    //@TableField("PUSERFLD18")
    private String puserfld18;

    //@TableField("PUSERFLD19")
    private String puserfld19;

    //@TableField("PUSERFLD20")
    private String puserfld20;

    //@TableField("PRODJS")
    private Double prodjs;

    //@TableField("JTQTY")
    private Double jtqty;

    //@TableField("PLANERI")
    private String planeri;

    //@TableField("SCRDATE")
    private String scrdate;

    //@TableField("APCODE")
    private String apcode;

    //@TableField("LASTUPD")
    private String lastupd;

    //@TableField("applyId")
    private Long applyId;

    //@TableField("sha1_value")
    private String sha1Value;

    //@TableField("isNeedUpd")
    private Integer isNeedUpd;

    //@TableField("updAction")
    private String updAction;

    //@TableField("isDeal")
    private Integer isDeal;

    //@TableField("DealDate")
    private String dealDate;

    //@TableField("errCode")
    private String errCode;

    //@TableField("errMsg")
    private String errMsg;

    //@TableField("qingflowCode")
    private String qingflowCode;

    //@TableField(value = "lastRequestId",updateStrategy = FieldStrategy.IGNORED,insertStrategy = FieldStrategy.IGNORED)
    private String lastRequestId;

    //@TableField("isWaiting")
    private Integer isWaiting;

    //@TableField("actionResult")
    private String actionResult;

    //private ProutingMainModel proutingMain;

    private List<BomworkRoutingModel> routingLists;


    private String invName;
    private String invStd;
    private String cusCode;//客户代号
    private String cusName;//客户名称
    private String orderStatus;//工单状态 未开始
    private String vpnoLast;//批号日期 240731
    private String proutingName;//工艺路线
    private String  invPIC;//产品图片
    private String invSOP;//产品SOP
    private Long needDays;//预计天数

    private String orderSouceType;//数据来源

    public void Copy(BomworkEntity entity){
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        //main_id
        this.mainId=entity.getMainId();

        //ERI
        this.eri=entity.getEri();
        //SRCERI
        this.srceri=entity.getSrceri();
        //SDATE
        if(entity.getSdate()==null)
            this.sdate=null;
        else
            this.sdate= entity.getSdate().format(formatter);

        //CODE
        this.code=entity.getCode();
        //MAKER
        //这个是编码，需要名称

        if(PubInfoUtils.mapMakeList==null||PubInfoUtils.mapMakeList.isEmpty()){
            this.maker=entity.getMaker();
        }
        else{
            if (PubInfoUtils.mapMakeList.containsKey(entity.getMaker())){
                this.maker=PubInfoUtils.mapMakeList.get(entity.getMaker());
            }
            else {
                this.maker=entity.getMaker();
            }
        }


        //MPROD
        this.mprod=entity.getMprod();
        //QTY
        if(entity.getQty()==null){
            this.qty=0;
        }
        else{
            this.qty=Math.round(entity.getQty());

        }
        //this.qty= entity.getQty();
        //SRCQTY
        //this.srcqty=entity.getSrcqty();
        if(entity.getSrcqty()==null){
            this.srcqty=0;
        }
        else{
            this.srcqty=Math.round(entity.getSrcqty());

        }
        //DUEDATE
        //this.duedate=entity.getDuedate();
        if(entity.getDuedate()==null)
            this.duedate=null;
        else
            this.duedate=entity.getDuedate().format(formatter);
        //PROJNO
        this.projno=entity.getProjno();
        //CLOSETYPE
        this.closetype=entity.getClosetype();
        //LINDATE
        //this.lindate=entity.getLindate();

        if(entity.getLindate()==null)
            this.lindate=null;
        else
            this.lindate=entity.getLindate().format(formatter);//sdf.format(entity.getLindate());

        //ENDDATE
       //this.enddate=entity.getEnddate();

        if(entity.getEnddate()==null)
            this.enddate=null;
        else
            this.enddate=entity.getEnddate().format(formatter);//sdf.format(entity.getEnddate());



        //PRNIMMED
        this.prnimmed=entity.getPrnimmed();
        //PRNONCE
        this.prnonce=entity.getPrnonce();
        //ACCGEN
        this.accgen=entity.getAccgen();
        //DPTNO
        this.dptno=entity.getDptno();
        //ACCNO
        this.accno=entity.getAccno();
        //ACCDESC
        this.accdesc=entity.getAccdesc();
        //INQTY
        this.inqty=entity.getInqty();
        //GOTQTY
        this.gotqty=entity.getGotqty();
        //COMQTY
        this.comqty=entity.getComqty();
        //ARTICLE
        this.article=entity.getArticle();
        //MEMO
        this.memo=entity.getMemo();
        //EDITOR
        this.editor=entity.getEditor();
        //SCRUTINY
        this.scrutiny=entity.getScrutiny();
        //ADSTSUBJ
        this.adstsubj=entity.getAdstsubj();
        //SUBJAMT
        this.subjamt=entity.getSubjamt();
        //WORKSUBJ
        this.worksubj=entity.getWorksubj();
        //EXPSUBJ
        this.expsubj=entity.getExpsubj();
        //INCOST
        this.incost=entity.getIncost();
        //PRODCOST
        this.prodcost=entity.getProdcost();
        //WORKCOST
        this.workcost=entity.getWorkcost();
        //EXP
        this.exp=entity.getExp();
        //PLUSSUB
        this.plussub=entity.getPlussub();
        //TOTCOST
        this.totcost=entity.getTotcost();
        //CLOSEPRC
        this.closeprc=entity.getCloseprc();
        //TPROD
        this.tprod=entity.getTprod();
        //TQTY
        this.tqty=entity.getTqty();
        //TSERIAL
        this.tserial=entity.getTserial();
        //SHIPMARK
        this.shipmark=entity.getShipmark();
        //SHIPMARKERI
        this.shipmarkeri=entity.getShipmarkeri();
        //SPEC
        this.spec=entity.getSpec();
        //WORKTYPE
        this.worktype=entity.getWorktype();
        //BEGINDATE
        //this.begindate=entity.getBegindate();
        if(entity.getBegindate()==null)
            this.begindate=null;
        else
            this.begindate=entity.getBegindate().format(formatter);//sdf.format(entity.getBegindate());
        //RBEGINDATE
        //this.rbegindate=entity.getRbegindate();
        if(entity.getRbegindate()==null)
            this.rbegindate=null;
        else
            this.rbegindate=entity.getRbegindate().format(formatter);//sdf.format(entity.getRbegindate());
        //CURR
        this.curr=entity.getCurr();
        //SPRICE
        this.sprice=entity.getSprice();
        //SEXP
        this.sexp=entity.getSexp();
        //SEXPSUBJ
        this.sexpsubj=entity.getSexpsubj();
        //GWN
        this.gwn=entity.getGwn();
        //BQTY
        this.bqty=entity.getBqty();
        //RCOSTFLAG
        this.rcostflag=entity.getRcostflag();
        //PCODE
        this.pcode=entity.getPcode();
        //PWTYPE
        this.pwtype=entity.getPwtype();
        //INVERTFLAG
        this.invertflag=entity.getInvertflag();
        //QTQTY
        this.qtqty=entity.getQtqty();
        //PLANDAY
        this.planday=entity.getPlanday();
        //STATUS1
        this.status1=entity.getStatus1();
        //STATUS2
        this.status2=entity.getStatus2();
        //STATUS3
        this.status3=entity.getStatus3();
        //STATUS4
        this.status4=entity.getStatus4();
        //EDITORCODE
        this.editorcode=entity.getEditorcode();
        //LASTEDITOR
        this.lasteditor=entity.getLasteditor();
        //COMPNO
        this.compno=entity.getCompno();
        //NEEDPRS
        this.needprs=entity.getNeedprs();
        //SRCTRACK
        this.srctrack=entity.getSrctrack();
        //PRODPRSNO
        this.prodprsno=entity.getProdprsno();
        //VPNO
        this.vpno=entity.getVpno();
        //VLIDDATE
        //this.vliddate=entity.getVliddate();
        if(entity.getVliddate()==null)
            this.vliddate=null;
        else
            this.vliddate=entity.getVliddate().format(formatter);//sdf.format(entity.getVliddate());
        //STATUS5
        this.status5=entity.getStatus5();
        //STATUS6
        this.status6=entity.getStatus6();
        //STATUS7
        this.status7=entity.getStatus7();
        //STATUS8
        this.status8=entity.getStatus8();
        //STATUS9
        this.status9=entity.getStatus9();
        //STATUS10
        this.status10=entity.getStatus10();
        //NEDERI
        this.nederi=entity.getNederi();
        //ORDERI
        this.orderi=entity.getOrderi();
        //WORKTIME
        this.worktime=entity.getWorktime();
        //MERGEERI
        this.mergeeri=entity.getMergeeri();
        //MERGEFLAG
        this.mergeflag=entity.getMergeflag();
        //OLDBEGINDATE

        //this.oldbegindate=entity.getOldbegindate();
        if(entity.getOldbegindate()==null)
            this.oldbegindate=null;
        else
            this.oldbegindate=entity.getOldbegindate().format(formatter);//sdf.format(entity.getOldbegindate());

        //OLDDUEDATE
        //this.oldduedate=entity.getOldduedate();
        if(entity.getOldduedate()==null)
            this.oldduedate=null;
        else
            this.oldduedate=entity.getOldduedate().format(formatter);//sdf.format(entity.getOldduedate());
        //PKERI
        this.pkeri=entity.getPkeri();
        //GETQTY
        this.getqty=entity.getGetqty();
        //OUQTY
        this.ouqty=entity.getOuqty();
        //OTHERUNIT
        this.otherunit=entity.getOtherunit();
        //INOUQTY
        this.inouqty=entity.getInouqty();
        //OUQTYNOTCALC
        this.ouqtynotcalc=entity.getOuqtynotcalc();
        //ADSTINQTY
        this.adstinqty=entity.getAdstinqty();
        //ADSTINAMT
        this.adstinamt=entity.getAdstinamt();
        //PRSWORKCOST
        this.prsworkcost=entity.getPrsworkcost();
        //PRSEXP
        this.prsexp=entity.getPrsexp();
        //PRSSEXP
        this.prssexp=entity.getPrssexp();
        //ISTODSPWORK
        this.istodspwork=entity.getIstodspwork();
        //AMEXP
        this.amexp=entity.getAmexp();
        //ISPRSALLT
        this.isprsallt=entity.getIsprsallt();
        //MEDQTY
        this.medqty=entity.getMedqty();
        //ISDSGWORK
        this.isdsgwork=entity.getIsdsgwork();
        //PHSQTY
        this.phsqty=entity.getPhsqty();
        //BOMVER
        this.bomver=entity.getBomver();
        //ORDBOMERI
        this.ordbomeri=entity.getOrdbomeri();
        //TOTWORKTIME
        this.totworktime=entity.getTotworktime();
        //OMEDQTY
        this.omedqty=entity.getOmedqty();
        //USECOST1
        this.usecost1=entity.getUsecost1();
        //USECOST2
        this.usecost2=entity.getUsecost2();
        //USECOST3
        this.usecost3=entity.getUsecost3();
        //USECOST4
        this.usecost4=entity.getUsecost4();
        //USECOST5
        this.usecost5=entity.getUsecost5();
        //USECOST6
        this.usecost6=entity.getUsecost6();
        //USECOST7
        this.usecost7=entity.getUsecost7();
        //USECOST8
        this.usecost8=entity.getUsecost8();
        //USECOST9
        this.usecost9=entity.getUsecost9();
        //USECOST10
        this.usecost10=entity.getUsecost10();
        //AUDITSTATE
        this.auditstate=entity.getAuditstate();
        //BOMTYPE
        this.bomtype=entity.getBomtype();
        //BOMERI
        this.bomeri=entity.getBomeri();
        //HASBOMWORK3
        this.hasbomwork3=entity.getHasbomwork3();
        //SCRUTINY1
        this.scrutiny1=entity.getScrutiny1();
        //SCRDATE1
        //this.scrdate1=entity.getScrdate1();
        if(entity.getScrdate1()==null)
            this.scrdate1=null;
        else
            this.scrdate1=entity.getScrdate1().format(formatter);//sdf.format(entity.getScrdate1());
        //DISVARY
        this.disvary=entity.getDisvary();
        //SPLITERI
        this.spliteri=entity.getSpliteri();
        //SPLITQTY
        this.splitqty=entity.getSplitqty();
        //SPLITFLAG
        this.splitflag=entity.getSplitflag();
        //EQUIPCODE
        this.equipcode=entity.getEquipcode();
        //PUSERFLD1
        this.puserfld1=entity.getPuserfld1();
        //PUSERFLD2
        this.puserfld2=entity.getPuserfld2();
        //PUSERFLD3
        this.puserfld3=entity.getPuserfld3();
        //PUSERFLD4
        this.puserfld4=entity.getPuserfld4();
        //PUSERFLD5
        this.puserfld5=entity.getPuserfld5();
        //PUSERFLD6
        this.puserfld6=entity.getPuserfld6();
        //PUSERFLD7
        this.puserfld7=entity.getPuserfld7();
        //PUSERFLD8
        this.puserfld8=entity.getPuserfld8();
        //PUSERFLD9
        this.puserfld9=entity.getPuserfld9();
        //PUSERFLD10
        this.puserfld10=entity.getPuserfld10();
        //PUSERFLD11
        this.puserfld11=entity.getPuserfld11();
        //PUSERFLD12
        this.puserfld12=entity.getPuserfld12();
        //PUSERFLD13
        this.puserfld13=entity.getPuserfld13();
        //PUSERFLD14
        this.puserfld14=entity.getPuserfld14();
        //PUSERFLD15
        this.puserfld15=entity.getPuserfld15();
        //PUSERFLD16
        this.puserfld16=entity.getPuserfld16();
        //PUSERFLD17
        this.puserfld17=entity.getPuserfld17();
        //PUSERFLD18
        this.puserfld18=entity.getPuserfld18();
        //PUSERFLD19
        this.puserfld19=entity.getPuserfld19();
        //PUSERFLD20
        this.puserfld20=entity.getPuserfld20();
        //PRODJS
        this.prodjs=entity.getProdjs();
        //JTQTY
        this.jtqty=entity.getJtqty();
        //PLANERI
        this.planeri=entity.getPlaneri();
        //SCRDATE
        //this.scrdate=entity.getScrdate();
        if(entity.getScrdate()==null)
            this.scrdate="";
        else
            this.scrdate=entity.getScrdate().format(formatter);//sdf.format(entity.getScrdate());
        //APCODE
        this.apcode=entity.getApcode();
        //LASTUPD
        this.lastupd=entity.getLastupd();
        //applyId
        this.applyId=entity.getApplyId();
        //sha1_value
        this.sha1Value=entity.getSha1Value();
        //isNeedUpd
        this.isNeedUpd=entity.getIsNeedUpd();
        //updAction
        this.updAction=entity.getUpdAction();
        //isDeal
        this.isDeal=entity.getIsDeal();
        //DealDate
        //this.dealDate=entity.getDealDate();
        if(entity.getDealDate()==null)
            this.dealDate=null;
        else
            this.dealDate=entity.getDealDate().format(formatter);//sdf.format(entity.getDealDate());
        //errCode
        this.errCode=entity.getErrCode();
        //errMsg
        this.errMsg=entity.getErrMsg();
        //qingflowCode
        this.qingflowCode=entity.getQingflowCode();
        //lastRequestId
        this.lastRequestId=entity.getLastRequestId();
        //isWaiting
        this.isWaiting=entity.getIsWaiting();
        //actionResult
        this.actionResult=entity.getActionResult();

        if(vpno==null||vpno.isEmpty()){

        }
        else if(vpno.length()<6){
            vpnoLast=vpno;
        }
        else{
            vpnoLast=vpno.substring(vpno.length()-6);
        }

        needDays= ChronoUnit.DAYS.between(entity.getBegindate(),entity.getDuedate())+1;


    }

    public void LoadRouting(JdbcTemplate mySqlJdbc) throws Exception{

        String strSql="SELECT getInvDefRouting('"+this.mprod+"')";
        String strDefRouting=mySqlJdbc.queryForObject(strSql,String.class);
        proutingName=strDefRouting;

        if(strDefRouting==null||strDefRouting.equals("")){
             throw new Exception("工艺路线未定义!");
        }
        try {


            strSql = "SELECT a.main_id,a.qingApplyId,a.downBatchId,a.qingRowCode," +
                    " a.qingApplyUser,a.qingApplyDate,a.qingUpdateDate,\n" +
                    " a.qingRowState,a.routingCode,a.routingName,a.routingAdd,a.routingState,a.randcodes,a.mainmemo\n" +
                    " from qing_proutingmain a\n" +
                    " INNER JOIN qing_downdatabatch c on a.downBatchId=c.downBatchId\n" +
                    " where a.routingName=? and c.isValid=1";

            ProutingMainModel proutingMain= mySqlJdbc.queryForObject(strSql, new BeanPropertyRowMapper<>(ProutingMainModel.class), strDefRouting);

            strSql="SELECT b.detail_id,b.main_id,b.qingApplyId," +
                    " b.opSeq,b.opCode,b.opName," +
                    " b.opRefer,b.opRatio,b.isFirstFlag,b.isLastFlag,\n" +
                    " b.detailmemo\n" +
                    "from qing_proutingmain a\n" +
                    "INNER JOIN qing_proutingdetail b on a.main_id=b.main_id\n" +
                    "where b.main_id=?";


            List<PRoutingDetailModel> Proutingdetails = mySqlJdbc.query(strSql, new BeanPropertyRowMapper<>(PRoutingDetailModel.class), proutingMain.getMainId());

            proutingMain.setDetails(Proutingdetails);

            if(Proutingdetails==null||Proutingdetails.size()<1){
                throw new Exception("工艺路线明细未定义!");
            }
            routingLists=new ArrayList<>();

            for (int i = 0; i < Proutingdetails.size(); i++) {
                BomworkRoutingModel bomworkRoutingModel=new BomworkRoutingModel();
                PRoutingDetailModel pRoutingDetailModel=Proutingdetails.get(i);
                bomworkRoutingModel.CopyData(pRoutingDetailModel);
                bomworkRoutingModel.setOpQty(this.qty);
                bomworkRoutingModel.setProBatchCode(this.vpno);
                //detailRowStatus;//状态 未开始，已启动，暂停，已结束
                bomworkRoutingModel.setDetailRowStatus("未开始");

                if (i==0){
                    bomworkRoutingModel.setIsFirstFlag("是");
                }
                else{
                    bomworkRoutingModel.setIsFirstFlag("否");
                }

                if(i==Proutingdetails.size()-1){
                    bomworkRoutingModel.setIsLastFlag("是");
                }
                else {
                    bomworkRoutingModel.setIsLastFlag("否");
                }

                bomworkRoutingModel.setPlanStartTime(begindate);
                bomworkRoutingModel.setPlanEndTime(duedate);

                routingLists.add(bomworkRoutingModel);


            }












        }
        catch (Exception e){
            e.printStackTrace();
            throw  e;
        }

    }

    public void LoadInvExtendInfo(JdbcTemplate mySqlJdbc) throws Exception{

        String strSql="select count(*)  "+
                "FROM product_info a\n" +
                "LEFT OUTER JOIN qing_productpicsop b on a.applyId=b.qingApplyId\n" +
                "where invCode=?";
        int iHaveCount=mySqlJdbc.queryForObject(strSql,Integer.class,this.mprod);
        if(iHaveCount<1){
            throw new Exception("在产品表product_info中未发现当前物料"+this.mprod+"!");
        }

        strSql="SELECT a.invName,a.invStd,a.cusCode,a.cusName,b.invPIC,b.invSOP \n" +
                "FROM product_info a\n" +
                "LEFT OUTER JOIN qing_productpicsop b on a.applyId=b.qingApplyId\n" +
                "where invCode=?";

        ProductToBomWorkInfo productToBomWorkInfo=mySqlJdbc.queryForObject(strSql, new BeanPropertyRowMapper<>(ProductToBomWorkInfo.class),this.mprod);
        if(productToBomWorkInfo==null){

        }
        else{
            this.invName=productToBomWorkInfo.getInvName();
            this.invStd=productToBomWorkInfo.getInvStd();
            this.cusCode=productToBomWorkInfo.getCusCode();
            this.cusName=productToBomWorkInfo.getCusName();
            this.invPIC=productToBomWorkInfo.getInvPIC();
            this.invSOP=productToBomWorkInfo.getInvSOP();
        }
    }



}
